import {createSlice} from "@reduxjs/toolkit";
import type {PayloadAction} from "@reduxjs/toolkit";

interface Istate {
    count:number,
    message:string,
    direction:"left" | "right" | "up" | "down",
    names:string[]
}

const initialState:Istate = {
    count:100,
    message:"hello,react",
    direction:"left",
    names:[]
}

const counterSlice = createSlice({
    name:"counter",
    initialState,
    reducers:{
        changeMessageAction(state,actions:PayloadAction<string>){
            state.message = actions.payload;
        }
    }
});

export const {changeMessageAction} = counterSlice.actions;
export default counterSlice.reducer;
